//引入axios
import request from '@/utils/requset';
//获取所有权限列表 //树状图
async function getquanxian(type: string) {
  const data = await request(
    `http://106.12.150.223:8090/api/private/v1/rights/${type}`,
    'GET',
    {
      type: type,
    }
  );
  return data;
}
//获取角色管理
async function getguanli() {
  const data = await request(
    `http://106.12.150.223:8090/api/private/v1/roles`,
    'GET'
  );
  return data;
}
//删除指定角色权限
async function delquanxian(roled: number, rightld: number) {
  const data = await request(
    `http://106.12.150.223:8090/api/private/v1/roles/${roled}/rights/${rightld}`,
    'DELETE'
  );
  return data;
}
//添加角色
async function postjuese(name: string, rloe: string) {
  const data = await request(
    `http://106.12.150.223:8090/api/private/v1/roles`,
    'POST',
    {
      roleName: name,
      roleDesc: rloe,
    }
  );
  return data;
}
//编辑角色
async function putjuese(id: number, name: string, rloe?: string) {
  const data = await request(
    `http://106.12.150.223:8090/api/private/v1/roles/${id}`,
    'PUT',
    {
      roleName: name,
      roleDesc: rloe,
    }
  );
  return data;
}
//删除角色
async function deljuese(id: number) {
  const data = await request(
    `http://106.12.150.223:8090/api/private/v1/roles/${id}`,
    'DELETE'
  );
  return data;
}
//角色授权
async function postshouquan(id: number, rloe: string) {
  const data = await request(
    `http://106.12.150.223:8090/api/private/v1/roles/${id}/rights`,
    'POST',
    {
      rids: rloe,
    }
  );
  return data;
}
export default {
  getquanxian,
  getguanli,
  delquanxian,
  postjuese,
  putjuese,
  deljuese,
  postshouquan,
};
